package top.wardyan.wmes.rfid.pub;

import java.util.List;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jfinal.core.ActionKey;
import com.jfinal.core.Path;

import top.wardyan.common.ctrl.BaseController;
import top.wardyan.wmes.rfid.kqa.dto.ConterInfoDto;
import top.wardyan.wmes.rfid.kqa.dto.DrvCmdTempDto;
import top.wardyan.wmes.rfid.kqa.vo.BaseRequest;
import top.wardyan.wmes.rfid.kqa.vo.BaseResponse;

/**
 * @author lcf
 * @CreateTime 2022/1/19 13:49
 * @Description 工位机数据
 */
@Path("/device")
@SuppressWarnings("unchecked")
public class DeviceDataController extends BaseController {

	private static final cn.hutool.log.Log log = cn.hutool.log.Log.get();
	
	@ActionKey("/upload-data")
    public void uploadDeviceData(){
//        //log.info("上传设备数据，请求参数为：" + JSONObject.toJSON(request).toString());
//        BaseResponse<List<DrvCmdTempDto>> response = new BaseResponse<>();
////        DeviceDataUploadDto dto = request.getData();
////        List<DrvCmdTempDto> drvCmdTempDtoList = deviceDataService.uploadDeviceData(dto);
////        response.setSuccess(drvCmdTempDtoList);
//        this.renderJson(response);
        
        BaseRequest<List<DrvCmdTempDto>> params = this.getJson(BaseRequest.class);
  		if(log.isInfoEnabled()) {
  			log.info("上传设备数据,请求参数为:" + JSONObject.toJSONString(params));
  		}
  		BaseResponse<List<DrvCmdTempDto>> response = new BaseResponse<>();
  		// response.setSuccess("OK");
  		String s = "[{\"cmdContent\":\"string\",\"cmdMakeTime\":\"2020/01/01 00:00:00\",\"cmdNumber\":0,\"cmdType\":0,\"deviceCmdID\":0,\"did\":0,\"gid\":0,\"retryTimes\":0}]";
  		List<DrvCmdTempDto> dto = JSONArray.parseArray(s, DrvCmdTempDto.class);
  		response.setData(dto);
  		this.renderJson(response);
    }
}
